= form_for @user, builder: Tenon::FormBuilder do |f|
  .toolbar.bg-color-primary-dk10
    = render 'tenon/shared/breadcrumbs'
    .actions
      - if policy(@user).publish?
        %button.action-btn.btn.btn-flat.submit{ data: { disable_with: "Please wait..." } } Save

      %a.action-icon.dropdown-button{ href: '#!', data: { activates: 'form-dropdown'} }
        = i('more_vert')

      %ul.dropdown-content#form-dropdown
        - if policy(Tenon::ItemVersion).create?
          = render 'tenon/shared/draft_controls', obj: @user

        - if @user.persisted?
          %li
            = link_to @user, data: { method: :delete, confirm: 'Are you sure you want to delete this?' }, class: 'delete-link' do
              = i('delete')

  %main
    = error_messages_for :user

    = f.text_field :email, required: true, class: 'form-title-field', autofocus: true, autocomplete: 'off'

    .form-label Password
    .panel.block
      - if @user.persisted?
        = f.super_label :password, "New Password"
      - else
        = f.super_label :password
      = f.password_field :password, autocomplete: 'off'

      - if @user.persisted?
        = f.super_label :password_confirmation, "Confirm New Password"
      - else
        = f.super_label :password_confirmation, "Confirm Password"
      = f.password_field :password_confirmation

    .form_label Roles
    .panel.block
      .explanation Roles define a user's abilities throughout the site.
      - @roles.each do |role|
        - unless (role.title == "Super Admin" && !current_user.super_admin?) || (role.title == "Admin" && !current_user.admin?)
          = check_box_tag('user[role_ids][]', role.id, @user.role_ids.include?(role.id), class: 'tn-checkbox-right', id: "role_id_#{role.id}")
          %label{ for: "role_id_#{role.id}" }= role.title
          .spacer

    .form_label Actions
    .panel.block
      = f.check_box :approved

